package cn.swufe.edu.stu.hw_tools.Convert;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;

import android.app.Activity;
import android.app.ActivityOptions;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

import cn.swufe.edu.stu.hw_tools.MainList_P1;
import cn.swufe.edu.stu.hw_tools.R;

public class Dis_CV_Activity extends AppCompatActivity {
    private double input;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_dis_cv);

    }

    public void back(View btn){
        if(getResources().getResourceEntryName(btn.getId()).equals("CV1Back")){
            Intent intent = getIntent();
            setResult(2,intent);
            finish();
        }else if(getResources().getResourceEntryName(btn.getId()).equals("CV1Search")){
            TextView v0 = findViewById(R.id.CV1editTextText);
            try{
                input = Double.parseDouble(v0.getText().toString());
                String sinput = String.format("%.8f",input);
                double afinput = Double.parseDouble(sinput);
                TextView v1 = findViewById(R.id.CV1View1);
                double s1 = afinput * 0.0005400;
                String ss1 = v1.getText().toString();
                ss1 += String.format("%.8f",s1);
                v1.setText(ss1);
                TextView v2 = findViewById(R.id.CV1View2);
                double s2 = afinput * 0.0006213;
                String ss2 = v2.getText().toString();
                ss2 += String.format("%.8f",s2);
                v2.setText(ss2);
                TextView v3 = findViewById(R.id.CV1View3);
                double s3 = afinput * 3.2808398;
                String ss3 = v3.getText().toString();
                ss3 += String.format("%.8f",s3);
                v3.setText(ss3);
                TextView v4 = findViewById(R.id.CV1View4);
                double s4 = afinput * 3.0000000;
                String ss4 = v4.getText().toString();
                ss4 += String.format("%.8f",s4);
                v4.setText(ss4);
                TextView v5 = findViewById(R.id.CV1View5);
                double s5 = afinput * 30.0000000;
                String ss5 = v5.getText().toString();
                ss5 += String.format("%.8f",s5);
                v5.setText(ss5);
            }catch (Exception e){
                Toast.makeText(this, "٩(๑òωó๑)۶输入数字啊，大哥~", Toast.LENGTH_SHORT).show();
            }

        }

    }

}